unit clx;

interface
uses
  DateUtils,SysUtils;
  
type
  TSex=(Female=0,Male=1);
  TPayType=(ptProduction=0,ptHour=1,ptFlat=2);
  TNTFType=(ntftLocal=0,ntftWait=1,ntftNone=2);
  
  TWorker=class(TObject)
    private
      FID:Cardinal;
      FName:string;
      FRFID:string;
      FSex:TSex;
      FBirthday:TDateTime;
      FColor:string;
      FGroup:Cardinal;
      FPayType:TPayType;
      FNTFType:TNTFType;
      FSuperRate:Double;
      FTaxRate:Double;
      FPenalty:Double;
    protected
      procedure SetName(value:string);
      procedure SetRFID(value:string);
      procedure SetSex(value:TSex);
      procedure SetBirthday(value:TDateTime);
      function GetAge:Byte;
      procedure SetColor(value:string);
      Procedure SetGroup(value:Cardinal);
      Procedure SetPayType(value:TPayType);
      Procedure SetNTFType(value:TNTFType);
      Procedure SetSuperRate(value:Double);
      Procedure SetTaxRate(value:Double);
      Procedure SetPenalty(value:Double);
    published
      property ID:Cardinal Read FID;
      property Name:string Read FName Write SetName;
      property RFID:string Read FRFID Write SetRFID;
      property Sex:TSex Read FSex Write SetSex;
      property Birthday:TDateTime Read FBirthday Write SetBirthday;
      property Age:Byte Read GetAge;
      property Color:string Read FColor Write SetColor;
      property Group:Cardinal Read FGroup Write SetGroup;
      Property PayType:TPayType Read FPayType Write SetPayType;
      Property NTFType:TNTFType Read FNTFType Write SetNTFType;
      Property SuperRate:Double Read FSuperRate Write SetSuperRate;
      Property TaxRate:Double Read FTaxRate Write SetTaxRate;
      Property Penalty:Double Read FPenalty Write SetPenalty;
    public
      Constructor Create;overload;
      Constructor Create(RFID:string); overload;
      Destructor Destroy;
      procedure StartWork();
      procedure GoOffWork();
      procedure GetPunnets();
      procedure CalcPayment();
  end;

implementation

Constructor TWorker.Create;
begin
  inherited Create;
end;

Constructor TWorker.Create(RFID:string);
begin

end;

Destructor TWorker.Destroy;
begin
  inherited Destroy;
end;

procedure TWorker.StartWork();
begin

end;

procedure TWorker.GoOffWork();
begin

end;

procedure TWorker.GetPunnets();
begin

end;

procedure TWorker.CalcPayment();
begin

end;

procedure TWorker.SetName(value:string);
begin
  FName:=value;
end;

procedure TWorker.SetRFID(value:string);
begin
  FRFID:=value;
end;

procedure TWorker.SetSex(value:TSex);
begin
  FSex:=value;
end;

procedure TWorker.SetBirthday(value:TDateTime);
begin
  FBirthday:=value;
end;

function TWorker.GetAge:Byte;
begin
  Result:=YearOf(Date)-YearOf(FBirthday);
end;

procedure TWorker.SetColor(value:string);
begin
  if Length(Trim(value))>8 then begin
    Raise ERangeError.Create('Color Length must smaller than 8');
  end else begin
    FColor:=value;
  end;
end;

procedure TWorker.SetGroup(value:Cardinal);
begin
  FGroup:=value;
end;

Procedure TWorker.SetPayType(value:TPayType);
begin 
  FPayType:=value
end;
  
Procedure TWorker.SetNTFType(value:TNTFType);
begin 
  FNTFType:=value;
end;

Procedure TWorker.SetSuperRate(value:Double);
begin 
  if (value<0) or (value>1) then begin
    Raise ERangeError.Create('SuperRate must in range of [0,1]');
  end else begin
    FSuperRate:=value;
  end;
end;

Procedure TWorker.SetTaxRate(value:Double);
begin 
  if (value<0) or (value>1) then begin
    Raise ERangeError.Create('TaxRate must in range of [0,1]');
  end else begin
    FTaxRate:=value;
  end;
end;

Procedure TWorker.SetPenalty(value:Double);
begin 
  if (value<0) or (value>1) then begin
    Raise ERangeError.Create('Penalty must in range of [0,1]');
  end else begin
    FPenalty:=value;
  end;
end;

end.
